package com.cloud.zk.controller;

import com.cloud.zk.service.ZooKeeperService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/zk")
@Slf4j
public class ZkController {
    @Autowired
    private ZooKeeperService zooKeeperService;

    // 创建节点
    @SneakyThrows
    @RequestMapping("/createNode")
    private void createNode() {
        zooKeeperService.createNode("testNode", "测试节点");
    }

    // 获取节点
    @RequestMapping("/getNodeData")
    @SneakyThrows
    private void getNodeData() {
        zooKeeperService.getNodeData(null);
    }

    @RequestMapping("/getChildren")
    @SneakyThrows
    private void getChildren() {
        zooKeeperService.getChildren(null);
    }

}
